package ac.technion.gcchat.messages;

import ac.technion.gcframework.serialization.IObjectSerializationAgent;
import ac.technion.gcframework.serialization.SerializationUtils;

/**
 * Generated on Fri Jul 22 15:43:13 IDT 2011
 */
public class MessageTypeSerializationAgent implements IObjectSerializationAgent
{
	public void serialize(Object obj, byte[] buf, int loc)
	{
		MessageType typedObj = (MessageType)obj;
		int fieldSize;

		fieldSize = SerializationUtils.getByteSerializationSize(typedObj.getType());
		SerializationUtils.serialize(typedObj.getType(), buf, loc);
		loc += fieldSize;
	}

	public Object deSerialize(byte[] buf, int loc)
	{
		MessageType obj = new MessageType();
		int size=0;
		size = SerializationUtils.getSerializedByteSize(buf, loc);
		obj.setType(SerializationUtils.deSerializeByte(buf, loc));
		loc += size;
		return obj;
	}

	public int getSerializationSize(Object obj)
	{
		MessageType typedObj = (MessageType)obj;

		int size=0;
		size += SerializationUtils.getByteSerializationSize(typedObj.getType());
		return size;
	}

	public int getSerializedSize(byte[] buf, int loc)
	{
		int totalSize = 0;
		int fieldSize;

		fieldSize = SerializationUtils.getSerializedByteSize(buf, loc);
		totalSize += fieldSize;
		loc += fieldSize;

		return totalSize;
	}
}